<?php

namespace App\Admin\Extensions;

use Dcat\Admin\Grid\Filter\Presenter\Select;

class SelectPresenter extends Select
{
    /**
     * 给 <select> 增加任意属性
     * @param array $attrs  例 ['id' => 'filter_tech', 'class' => 'form-control-sm']
     * @return $this
     */
    public function attribute(array $attrs)
    {
        // 合并到父类已有的 attributes 数组
        $this->variables['attributes'] = array_merge(
            $this->variables['attributes'] ?? [],
            $attrs
        );
        return $this;
    }

    public function select($options = [])
    {
        $this->options($options);
        return $this;
    }

    public function options($options = [])
    {
        $this->variables['options'] = $options;
        return $this;
    }

}